import requests

from common.config import getconf
from tests.new_rypark_background.get_cookie import internal_token


class ParkEnterRecord:
    # =====================进场记录=====================

    # 进场记录列表查询
    def query_enter_record_list(self, env, dict={}):
        base_url = getconf(env, "zhongtai_url")
        url = base_url + "platform-parking-server/v1/enterLeaveCar/enter/list/page?"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": internal_token(env)}
        if not dict:
            dict["parkingLotId"] = getconf(env, "parking_lot_id")
        return requests.post(url, headers=headers, json=dict).json()

    # 下拉可选停车场列表查询
    def query_parklot_list(self, env):
        base_url = getconf(env, "zhongtai_url")
        url = base_url + "platform-parking-server/parkingLot/" + getconf(env, "parking_lot_id") + "/childGarageInfo"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": internal_token(env)}
        return requests.get(url, headers=headers).json()

    # 下拉可选车库列表查询
    def query_child_garage_list(self, env):
        base_url = getconf(env, "zhongtai_url")
        url = base_url + "platform-parking-server/parkingLot/" + getconf(env, "parking_lot_id") + "/childGarageInfo"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": internal_token(env)}
        return requests.get(url, headers=headers).json()

    # 下拉可选车道列表查询
    def query_park_gate_list(self, env):
        base_url = getconf(env, "zhongtai_url")
        url = base_url + "platform-parking-server/parkingLot/" + getconf(env, "parking_lot_id") + "/childGateInfo"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": internal_token(env)}
        return requests.get(url, headers=headers).json()
